package com.linchong.concurrency.chapter5;

import java.util.stream.IntStream;

/**
 * @Author:linchong
 * @CreateTime:2020-01-03 22:04
 * @Description:join
 */
public class ThreadJoin {
	public static void main(String[] args) throws InterruptedException {
		Thread t1 = new Thread(() ->
				IntStream.range(1, 1000).
						forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i)));

		Thread t2 = new Thread(() ->
				IntStream.range(1, 1000).
						forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i)));
		t1.start();
		t2.start();
		t1.join();
		t2.join();
		System.out.println("all of tasks finish done;");
		IntStream.range(1, 1000).
				forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i));
	}

}
